//
//  NewSellerShortOrdersTableViewCell.m
//  智积分
//
//  Created by apple on 2018/5/15.
//  Copyright © 2018年 Cynic. All rights reserved.
//

#import "NewSellerShortOrdersTableViewCell.h"
#import "OperationView.h"
@implementation NewSellerShortOrdersTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


/*@property (nonatomic ,retain)UILabel *time;
 @property (nonatomic ,retain)UILabel *ordernum;
 @property (nonatomic ,retain)UILabel *buyyer;
 @property (nonatomic ,retain)UILabel *productionname;
 @property (nonatomic ,retain)UILabel *productioninfo;
 @property (nonatomic ,retain)UILabel *num;
 @property (nonatomic ,retain)UILabel *transMoney;
 @property (nonatomic ,retain)UILabel *costmoney;
 @property (nonatomic ,retain)UIButton *productionimg;*/
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    UIView *bottomview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, cx_wid, 10)];
    bottomview.backgroundColor = [CXSinglerModel colorWithHex:@"f3f4f6" alpha:1];
    [self.contentView addSubview:bottomview];
    [bottomview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(10);
    }];
    
    
    _time = [UILabel CXCreateLabelwithFrame:CGRectMake(13, 8, 150, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:14 withlabelTextColor:[CXSinglerModel colorWithHex:@"999999" alpha:1] withReturnLabel:YES beyoundview:self.contentView];
    _ordernum = [UILabel CXCreateLabelwithFrame:CGRectMake(cx_wid - 110, 8, 100, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:14 withlabelTextColor:[UIColor blackColor] withReturnLabel:YES beyoundview:self.contentView];
    _buyyer = [UILabel CXCreateLabelwithFrame:CGRectMake(13, 33, 150, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:14 withlabelTextColor:[CXSinglerModel colorWithHex:@"999999" alpha:1] withReturnLabel:YES beyoundview:self.contentView];
    _status = [UILabel CXCreateLabelwithFrame:CGRectMake(cx_wid - 110, 33, 100, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:14 withlabelTextColor:[CXSinglerModel colorWithHex:@"F97044" alpha:1] withReturnLabel:YES beyoundview:self.contentView];
    _ordernum.textAlignment = _status.textAlignment = NSTextAlignmentRight;
//    _productionname = [UILabel CXCreateLabelwithFrame:CGRectMake(78, 72, cx_wid - 78 - 69, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:13 withlabelTextColor:[UIColor blackColor] withReturnLabel:YES beyoundview:self.contentView];
//    _productionname.numberOfLines = 2;
//    _num = [UILabel CXCreateLabelwithFrame:CGRectMake(cx_wid - 35, 114, 25, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:13 withlabelTextColor:[CXSinglerModel colorWithHex:@"999999" alpha:1] withReturnLabel:YES beyoundview:self.contentView];
//    _num.textAlignment = NSTextAlignmentCenter;
//    _productioninfo = [UILabel CXCreateLabelwithFrame:CGRectMake(78, 114, cx_wid - 78 - 69, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:13 withlabelTextColor:[CXSinglerModel colorWithHex:@"999999" alpha:1] withReturnLabel:YES beyoundview:self.contentView];
//    _productionimg = [[UIButton alloc] initWithFrame:CGRectMake(12, 72, 60, 60)];
//    _productionimg.backgroundColor = [UIColor lightGrayColor];
//    [self.contentView addSubview:_productionimg];
    
    for (NSInteger index = 0; index < 2; index ++) {
        UILabel *parlabel = [[UILabel alloc] initWithFrame:CGRectZero];
        parlabel.font = [UIFont systemFontOfSize:14];
        if (index == 1) {
            parlabel.textAlignment = NSTextAlignmentRight;
            parlabel.textColor = [UIColor blackColor];
            _transMoney = parlabel;
        }
        else{
            parlabel.textColor = [CXSinglerModel colorWithHex:@"666666" alpha:1];
            parlabel.text = @"运费";
        }
        [self.contentView addSubview:parlabel];
        [parlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(-62);
            make.left.mas_equalTo(12 + (cx_wid - 24 - 30) * index);
            make.size.mas_equalTo(CGSizeMake(30, 16));
        }];
    }
    _costmoney = [UILabel CXCreateLabelwithFrame:CGRectMake(12, 196, cx_wid - 12 - 80, 16) withtTitle:@"" inColor:[UIColor clearColor] withHasBottomLayer:NO withbottomlayerHit:0 withBottomLayercolor:[UIColor clearColor] withLabelfont:13 withlabelTextColor:[UIColor blackColor] withReturnLabel:YES beyoundview:self.contentView];
    [_costmoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.size.mas_equalTo(CGSizeMake(cx_wid - 12 - 80, 16));
        make.bottom.mas_equalTo(-22);
    }];
    
    UIImageView *pointer = [UIImageView new];
    pointer.image = [UIImage imageNamed:@"返回"];
    [self.contentView addSubview:pointer];
    [pointer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.size.mas_equalTo(CGSizeMake(7, 12));
        make.bottom.mas_equalTo(-10 - 14);
    }];
    
    for (NSInteger index = 0; index < 2; index ++) {
        UIView *centerlayer = [[UIView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:centerlayer];
        [centerlayer mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.bottom.mas_equalTo(-10 - 40 * (index + 1));
            make.size.mas_equalTo(CGSizeMake(cx_wid, 1));
        }];
        centerlayer.backgroundColor = [CXSinglerModel colorWithHex:@"f3f4f6" alpha:1];
    }
    return self;
}

-(void)loadProductions:(NSArray *)productions{

    for (UIView *partView in self.contentView.subviews) {
        if ([partView isKindOfClass:[OperationView class]]) {
            [partView removeFromSuperview];
        }
    }
    for (NSInteger index = 0; index <productions.count; index ++) {
        NSDictionary *part = productions[index];
        OperationView *partView = [[OperationView alloc] initWithFrame:CGRectMake(0, 60 + index * 84, cx_wid, 84)];
        partView.productionname.text = part[@"goods_name"];
        partView.productioninfo.text = [self Nnll:part[@"goods_attr"] withPlace:@""];
        partView.num.text = [NSString stringWithFormat:@"x%@",part[@"goods_num"]];
        NSString *imgurl = [part[@"goods_sm_img"] containsString:@"http"] ? part[@"goods_sm_img"] : [NSString stringWithFormat:@"https:%@",part[@"goods_sm_img"]];
        [partView.productionimg sd_setBackgroundImageWithURL:[NSURL URLWithString:imgurl] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"logo1"]];
        [self.contentView addSubview:partView];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
